<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML>
<html>
<head>
<title>编辑角色管理</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<base href="<%=basePath%>">
<%@include file="../common/common_ui.jsp"%>
<script type="text/javascript">
	function check() {
		//验证名称
		if ($.trim($("#name").val()) == ""
				|| $.trim($("#name").val()) == null) {
			$("#role_name_alert").show();
			$("#role_name_content").text("角色名称不能为空!");
			$("#name").focus();
			return false;
		}
		//验证描述
		var memo =$.trim($("#memo").val());
		if (memo != ""&&memo.length>200) {
			$("#role_name_alert").show();
			$("#role_name_content").text("角色描述长度不能大于200!");
			$("#memo").focus();
			return false;
		}
		return true;
	}
	$(function(){
		/*
		* 保存角色信息
		*/
		$("#btnSave").click(function(){
			var id = $("#id").val();
			var name = $("#name").val();
			var memo = $("#memo").val();
			if(check()){
				$.post("<%=path%>/roleInfo/saveRoleInfo.do",{
					times:new Date().getTime(),
					id:id,
					name:name,
					memo:memo
				},function(a){
					var data=a.msg
					if (data == "addSuccess") {
						$("#role_name_alert").hide();
						$("#role_msg_alert").show();
						$("#role_msg_content").text("新增成功！");
					} else if (data == "updateSuccess") {
						$("#role_name_alert").hide();
						$("#role_msg_alert").show();
						$("#role_msg_content").text("更新成功！");
					} else {
						$("#role_name_alert").show();
						$("#role_name_content").text(data);
					}
				});
			}
		});
		/*
		* 关闭提示
		*/
		$(".close").click(function(){
			$("#role_name_alert").hide();
			$("#role_msg_alert").hide();
		});
	});
</script>

</head>
<body >
	<form name="frm" id="frm" action=""
		method="post">
		<input type="hidden" name="id" id="id" value="${roleInfo.id}" />
		<div id="role_name_alert" class="alert alert-danger mb_0 ng-binding"
			style="display: none;margin-bottom:1px">
			<span id="role_name_content"></span>
			<span class="close">&times;</span>
		</div>
		<div id="role_msg_alert" class="alert alert-success alert-dismissible"
			role="alert" style="display: none">
			<span id="role_msg_content"></span>
			<span class="close">&times;</span>
		</div>
			<table class="table table-bordered table-hover definewidth ">
				<tr>
					<td width=20%>名称:</td>
					<td width=80%>
					  <input class="form-control" style="width:200px"  id="name" name="name"
					  type="text" value="${roleInfo.name}" maxLength="50" required/>
					</td>
				</tr>
				<tr>
					<td width=20%>描述:</td>
					<td width=80%>
						<textarea class="form-control" id="memo" name="memo" style="width:200px;height:100px">${roleInfo.memo}</textarea>
					</td>
				</tr>
			</table>
			<center>
				<input type="button" name="btnSave" id="btnSave"
					class="btn btn-primary" value="保存"  />&nbsp;&nbsp;&nbsp;
				<input type="button" class="btn" value="关闭"
					onclick="javascript:window.close()" />
			</center>
	</form>
</body>
</html>